Ext.ns("SafeCheckView");
SafeCheckView = Ext.extend(Ext.Panel, {
    constructor : function(a) {
        Ext.applyIf(this, a);
        var all=this.initUIComponents();
        SafeCheckView.superclass.constructor.call(this, {
            id : "SafeCheckView",
            title : "安全检查管理",
            region : "center",
            layout : "border",
            border : false,
            iconCls : "menu-position",
            items : [all.yearGridPanel,all.yearGridSearchPanel,all.yearGridTreePanel]
        });
    },
    initUIComponents : function() {
         var yearGridComponents=new createyeargridview({
            topbar : {
                inputFormName : 'SafeCheckForm',
                topbarAdd:{
                    hidden:false
                },
                topbarDel:{
                    hidden:false
                }
            },
            search : {
                items : [ {
                    style : "margin:5px 5px 5px 5px;",
                    text : "安全检查名称"
                }, {
                    columnWidth : 0.2,
                    xtype : "textfield",
                    name : "Q_checkPlanName_S_LK",
                    maxLength : 256
                } ]
            },
            grid : {
                title : "安全检查列表",
                rowActions:true,
                listUrl : __ctxPath + "/safecheckplan/listSafeCheck.do",
                removeUrl : __ctxPath + "/safecheckplan/deleteSafeCheck.do",
                fields : [ "id", 'years','institution',"state",'checkPlanName', "describe", "planStartDate", "planEndDate","situation","state"],
                columns : [ {
                    header : "id",
                    dataIndex : "id",
                    hidden : true
                }, {
                    header : "年份",
                    dataIndex : "years",
                    width : 50,
                    hidden:true,
                    sortable : true
                }, {
                    header:"所属机构",
                    dataIndex:'institution',
                    width:100
                },{
                    header : "安全检查名称",
                    dataIndex : "checkPlanName",
                    width : 100
                }, {
                    header : "检查开始时间",
                    dataIndex : "planStartDate",
                    width : 70
                }, {
                    header : "检查结束时间",
                    dataIndex : "planEndDate",
                    width : 70
                },
                 {
                    header : "检查状态",
                    dataIndex : "state",
                    width : 70
                },{
                    header : "检查情况",
                    dataIndex : "id",
                    sortable : false,
                    width : 50,
                    renderer : function(j, i, g, m, h) {
                        var cfg={
                                checkId : g.data.id
                        }
                        var k = "";
                                k += '<button title="评估" value="" class="btn-showDetail" onclick=\'SafeCheckView.checkState('
                                    + JSON.stringify(cfg) + ')\'></button>';
                        return k;
                    }
                }
                , new Ext.grid.Column({
                    header : "隐患记录",
                    dataIndex : "scIdps",
                    sortable : false,
                    scope:this,
                    width :70,
                    renderer : function(j, i, g, m, h) {
                        var cfg={
                                hiddenDangerId : g.data.id,
                                years : g.data.years
                        }
                        var k = "";
                        k += '<button title="隐患记录" value="" class="btn-showDetail" onclick=\'SafeCheckView.hiddenRecored('
                            + JSON.stringify(cfg) + ')\'></button>';
                              
                                return k;
                    }
                })
                
                ]
            },
            tree : {
                treeUrl : __ctxPath + "/safecheckplan/treeLoadSafeCheck.do"
            }
            
        });
        return yearGridComponents;
    }
});

SafeCheckView.hiddenRecored = function(safeCheck){
	
    new HiddenDangerWindow({
        hiddenDangerId : safeCheck.hiddenDangerId,
        years :safeCheck.years
    }).show();
};


SafeCheckView.edit = function(id) {
    new SafeCheckForm({
        id : id,
        operation: Constant.Operation.EDIT
    }).show();
};
SafeCheckView.checkState = function(safeCheck){
	
    new CheckStateWindow({
        checkId : safeCheck.checkId,
        
    }).show();
};